home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / lin_alg.lha / lin_alg / vmatrix.dat < prev    next >
Text File  |  1993-08-08  |  4KB  |  136 lines

  1.  
  2.  
  3. -------------------------------------------------------------------------------
  4.         Verify Operations on Matrices
  5.  
  6.  
  7. ---> Test allocation and compatibility check
  8. The following matrices have been allocated
  9.  
  10. Matrix 1:4x1:20 'Matrix m1'
  11. Matrix 1:4x1:20 'Matrix m2'
  12. Matrix 1:4x0:19 'Matrix m3'
  13. Matrix 1:4x1:20 'Matrix m4'
  14. Status information reported for matrix m3:
  15.   Row lower bound ... 1
  16.   Row upper bound ... 4
  17.   Col lower bound ... 0
  18.   Col upper bound ... 19
  19.   No. rows ...........4
  20.   No. cols ...........20
  21.   No. of elements ....80
  22.   Name Matrix m3
  23.  
  24. Check matrices 1 & 2 for compatibility
  25. Check matrices 1 & 4 for compatibility
  26. m2 has to be compatible with m3 after resizing to m3
  27. m1 has to be compatible with m5 after resizing to m5
  28.  
  29. Matrix 1:5x1:25 'Matrix m5'
  30.  
  31. ---> Test operations that treat each element uniformly
  32. Writing zeros to m...
  33. Clearing m1 ...
  34. Comparing m1 with 0 ...
  35. Writing a pattern 8.625 by assigning to m(i,j)...
  36. Writing the pattern by assigning to m1 as a whole ...
  37. Comparing m and m1 ...
  38. Comparing (m=0) and m1 ...
  39.  
  40. Clear m and add the pattern
  41.    add the doubled pattern with the negative sign
  42.    subtract the trippled pattern with the negative sign
  43.  
  44. Verify comparison operations
  45.    (m=pattern)>0
  46.    (m=pattern)>-pattern
  47.    (m=-pattern)<-pattern/2
  48.  
  49. Assign 2*pattern to m by repeating additions
  50. Assign 2*pattern to m1 by multiplying by two 
  51. Multiply m1 by one half returning it to the 1*pattern
  52.  
  53. Assign -pattern to m and m1
  54. m = sqrt(sqr(m)); m1 = abs(m1); Now m and m1 have to be the same
  55.  
  56. Check out to see that sin^2(x) + cos^2(x) = 1
  57. Element (16,8) with value 1 differs the most from what
  58. was expected, 1, though the deviation 1.19209e-07 is small
  59.  
  60. Done
  61.  
  62.  
  63. ---> Test Binary Matrix element-by-element operations
  64.  
  65. Verify assignment of a matrix to the matrix
  66.  
  67. Adding the matrix to itself, uniform pattern 4.25
  68.   subtracting two matrices ...
  69.   subtracting the matrix from itself
  70.   adding two matrices together
  71.  
  72. Arithmetic operations on matrices with not the same elements
  73.    adding mp to the zero matrix...
  74.    making m = 3*mp and m1 = 3*mp, via add() and succesive mult
  75.    clear both m and m1, by subtracting from itself and via add()
  76.  
  77. Testing element-by-element multiplications and divisions
  78.    squaring each element with sqr() and via multiplication
  79.    compare (m = pattern^2)/pattern with pattern
  80.  
  81.  
  82. Comparison of two Matrices:
  83. Matrix 2:11x0:19 ''
  84. Matrix 2:11x0:19 ''
  85. Maximal discrepancy            0
  86.    occured at the point        (2,0)
  87.  Matrix 1 element is            4.25
  88.  Matrix 2 element is            4.25
  89.  Absolute error v2[i]-v1[i]        0
  90.  Relative error                0
  91.  
  92. ||Matrix 1||               850
  93. ||Matrix 2||               850
  94. ||Matrix1-Matrix2||                0
  95. ||Matrix1-Matrix2||/sqrt(||Matrix1|| ||Matrix2||)    0
  96.  
  97.  
  98. Done
  99.  
  100. ---> Verify norm calculations
  101.  
  102. Assign 10.25 to all the elements and check norms
  103.   1. (col) norm should be pattern*nrows
  104.   Inf (row) norm should be pattern*ncols
  105.   Square of the Eucl norm has got to be pattern^2 * no_elems
  106.  
  107. Done
  108.  
  109. ---> Verify determinant evaluation
  110. for a square matrix of size 20
  111.  
  112. Check to see that the determinant of the unit matrix is one
  113.     determinant is 1
  114. Check the determinant for the matrix with 2.5
  115.     at the diagonal
  116.     determinant is 9.09495e+07
  117. Check the determinant for the matrix with 2.5
  118.     at the anti-diagonal
  119. Check the determinant for the singular matrix
  120.     defined as above with zero first row
  121.     determinant is 0
  122. Check out the determinant of the Hilbert matrix
  123.     3x3 Hilbert matrix: exact determinant 1/2160 
  124.                               computed    1/2159.99
  125.     4x4 Hilbert matrix: exact determinant 1/6048000 
  126.                               computed    1/6.04788e+06
  127.     5x5 Hilbert matrix: exact determinant 3.749295e-12
  128.                               computed    3.75127e-12
  129.     7x7 Hilbert matrix: exact determinant 4.8358e-25
  130.                               computed    6.54014e-25
  131.     9x9 Hilbert matrix: exact determinant 9.72023e-43
  132.                               computed    -1.10127e-39
  133.     10x10 Hilbert matrix: exact determinant 2.16418e-53
  134.                               computed    -3.15323e-47
  135. Done
  136.